
function deleteBlog(id) {
    if (!confirm("确认删除该博客？")) return;
    if (isNaN(id)) return;
    $.ajax({
        type: 'POST',
        url: '/admin/blog/delete',
        data: {
            'id': id
        },
        async: false,
        success: function (result) {
            alert(result.msg)
        }
    })
    loadBlogList();
}

function loadBlogList(page) {
    if (arguments.length === 0) {
        page = $('#page').val();
    } else {
        $('#page').val(page);
    }
    const title = $('#title').val();
    $('#blogListContent').load('/admin/blog/search', {
        title: title.length === 0 ? null : title,
        typeId: $('#typeId').val(),
        recommend: $('#recommend').is(':checked') ? true : null,
        page: page
    });
}

$('#types').on('change', function () {
    const value = $("#types").find("option:selected").val();
    $('#typeId').val(value);
})
